#ifndef __FOC_H
#define __FOC_H

#include "main.h"
#include "FreeRTOS.h"
#include "task.h"
#include "cmsis_os.h"
#include "pid.h"

extern float Uu, Uv, Uw, Ualpha, Ubeta, dc_a, dc_b, dc_c, voltage_limit, voltage_power_supply;
extern float I_q, I_d;
extern float Vd;
extern PID pid;
extern float sensor_angle;

void SetDCVoltage(float U);

void SetPhaseVoltageSVPWM(float Uq, float Ud, float angle_el);

void SetPwm(float Ua, float Ub, float Uc);

float constrain(float amt, float low, float high);

void Check_Sensor(void);

void Motor_Run(void);

float electricAngle(void);

void CalSensorAngle(void);

float calIqId(float current_u, float current_v, float angle_el);

void Set_CurTorque(float Target);

#endif // !__FOC_H
